

#delimit;
set more off;

cd "C:\....\Replication files";
	
use "ENMI - replication.dta", clear;

/* Table A9 and A10 - ECM and ERMs	*/


	 #delimit;
			 set more off;
xtpcse D1.pvote
	D1.c.ensh_mi
		L1.c.ensh_mi pvote_l
	 
	     if inc_cab_l==1  , p correlation();

 
/* ECM models	*/

 #delimit;
 set more off;
xtpcse D1.pvote
	D1.c.ensh_mi#1.inc_cab_l 
	L1.c.ensh_mi#L1.1.inc_cab_l 
	D1.c.moderate#1.inc_cab_l 
	L1.c.moderate#L1.1.inc_cab_l
	L1.c.GDPgrowth#L1.1.inc_cab_l
	D1.c.GDPgrowth#1.1.inc_cab_l
		nparty 
 majelect federal directpres   pvote_l   if inc_cab_l==1 , p correlation();

 estimates store xtpcse_onlyincumbents;

#delimit;
		/* set more off;
xtpcse D1.pvote
	D1.c.ensh_mi 
	D1.c.moderate 		L1.c.ensh_mi pvote_l
	L1.c.moderate 
nparty
 majelect federal directpres     if prime_minister==1 , p correlation();
	*/
		
	
xtpcse D1.pvote
	D1.c.ensh_mi
	L1.c.ensh_mi pvote_l

	D1.c.moderate 
	L1.c.moderate 
	L1.c.GDPgrowth
	D1.c.GDPgrowth
	
	nparty
		 majelect federal directpres   if inc_cab_l==0, p ;	 
		 		
		estimates store xtpcse_onlyopposition;
	
		#delimit;
		set more off;
		
xtpcse D1.pvote
	D1.c.ensh_mi##i.inc_cab_l 
	L1.c.ensh_mi##L1.i.inc_cab_l 
	D1.c.moderate##i.inc_cab_l 
	L1.c.moderate##L1.i.inc_cab_l
	L1.c.GDPgrowth##L1.i.inc_cab_l
	D1.c.GDPgrowth##1.i.inc_cab_l
		pvote_l
	nparty
		 majelect federal directpres  , p ;	 

		estimates store xtpcse_full;

		

	
	
	/* Table A9	*/
		

#delimit;
 esttab xtpcse_onlyopposition xtpcse_onlyincumbents xtpcse_full
			using "figures\xtpcse_table1.rtf", replace  
		b(%10.3f) se scalars("rmse Root Mean Squared Error" "chi2 \u0935?{\super 2}" )
		obslast star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
		mtitles ("Opposition" "Incumbents"  "All Parties") 
		nogaps compress   nonumbers 
order(D.ensh_mi L.ensh_mi  
1.inc_cab_l#cD.ensh_mi
1L.inc_cab_l#cL.ensh_mi 
D.moderate
L.moderate
1.inc_cab_l#cD.moderate
1L.inc_cab_l#cL.moderate
D.GDPgrowth L.GDPgrowth 
1.inc_cab_l#cD.GDPgrowth 
1L.inc_cab_l#cL.GDPgrowth 
1.inc_cab_l  1L.inc_cab_l 

 nparty majelect federal directpres pvote_l _cons)  

keep(D.ensh_mi L.ensh_mi  

D.GDPgrowth L.GDPgrowth 
1.inc_cab_l  1L.inc_cab_l 
1.inc_cab_l#cD.ensh_mi
1L.inc_cab_l#cL.ensh_mi 
1.inc_cab_l#cD.GDPgrowth 
1L.inc_cab_l#cL.GDPgrowth 

D.moderate
L.moderate
1.inc_cab_l#cD.moderate

1L.inc_cab_l#cL.moderate
 nparty majelect federal directpres pvote_l _cons)  
 coeflabels(D.ensh_mi "\u0916? ENMI"  
L.ensh_mi "ENMI{\sub t-1}" 
1.inc_cab_l "Incumbent{\sub t}"
1L.inc_cab_l "Incumbent{\sub t-1}"
1.inc_cab_l#cD.ensh_mi "Incumbent{\sub t} X \u0916? ENMI"
1L.inc_cab_l#cL.ensh_mi "Incumbent{\sub t-1} X ENMI{\sub t-1}"
D.GDPgrowth "\u0916? GDP Growth Rate"
L.GDPgrowth "GDP Growth Rate{\sub t-1}" 
1.inc_cab_l#cD.GDPgrowth "Incumbent{\sub t} X \u0916? GDP Growth Rate"
1L.inc_cab_l#cL.GDPgrowth "Incumbent{\sub t-1} X GDP Growth Rate{\sub t-1}"

1.inc_cab_l#cD.moderate  "Incumbent{\sub t} X \u0916? Moderated Position"
1L.inc_cab_l#cL.moderate "Incumbent{\sub t-1} X Moderated Position{\sub t-1}"

L.moderate "\u0916? Moderated Position"
D.moderate "Moderated Position{\sub t-1}"
nparty "Niche Party"
majelect "Majoritarian Election"
federal "Federal"
directpres "President"
pvote_l "% Vote{\sub t-1}"
_cons "Constant")
nonotes; 


/* Fixed Effect Models	*/

 #delimit;
 set more off;
xtreg D1.pvote
	D1.c.ensh_mi D1.c.GDPgrowth 
	D1.c.moderate 		L1.c.ensh_mi L1.c.GDPgrowth pvote_l
	L1.c.moderate
	
		nparty
 majelect federal directpres     if inc_cab_l==1 , fe vce(cluster party) ;

 estimates store xtpcse_onlyincumbents;

 		
	
xtreg D1.pvote
	D1.c.ensh_mi D1.c.GDPgrowth 
	L1.c.ensh_mi L1.c.GDPgrowth pvote_l
	L1.c.inc_cab_l#L1.c.ensh_mi
	L1.c.inc_cab_l#D1.c.ensh_mi
	D1.c.moderate 
	L1.c.moderate 
	
	nparty
		 majelect federal directpres   if inc_cab_l==0, fe  vce(cluster party) ;	 
		 		
		estimates store xtpcse_onlyoppposition;
	
		#delimit;
		set more off;
		
xtreg D1.pvote
	D1.c.ensh_mi##i.inc_cab_l 
	D1.c.moderate 
		L1.c.ensh_mi##L1.i.inc_cab_l 
		L1.c.GDPgrowth##L1.i.inc_cab_l 
		D1.c.GDPgrowth##i.inc_cab_l 
		pvote_l
	L1.c.moderate##L1.i.inc_cab_l D1.c.moderate##i.inc_cab_l
	nparty
		 majelect federal directpres  , fe vce(cluster party) ;	 

		estimates store xtpcse_full;

		
	

	/*Equilibrium response models - using McDonald and Best	*/
	 
		
	
 #delimit;
 set more off;
 
 		egen equil_pvote= mean(pvote) , by(party);
	gen pvote_lag= L1.pvote - equil_pvote;


xtpcse pvote

D1.c.ensh_mi#1.inc_cab_l 
L1.c.ensh_mi#L1.1.inc_cab_l
D1.c.GDPgrowth#1.inc_cab_l 
L1.c.GDPgrowth#L1.1.inc_cab_l
D1.c.moderate#1.inc_cab_l 
L1.c.moderate#L1.1.inc_cab_l
	
		nparty
 majelect federal directpres   equil_pvote pvote_lag if inc_cab_l==1  , p correlation();

 estimates store equil_onlyincumbents;

#delimit;
			 set more off;
xtpcse pvote
	D1.c.ensh_mi
	L1.c.ensh_mi

			
			D1.c.GDPgrowth L1.c.GDPgrowth
 D1.c.moderate L1.c.moderate
	
		nparty
 majelect federal directpres  equil_pvote pvote_lag   if prime_minister==1 , p correlation();
	
		
	
xtpcse pvote
D1.c.ensh_mi
L1.c.ensh_mi
L1.c.inc_cab_l#L1.c.GDPgrowth 
D1.c.GDPgrowth L1.c.GDPgrowth
D1.c.moderate L1.c.moderate
 
	nparty
		 majelect federal directpres equil_pvote  pvote_lag if inc_cab_l==0, p ;	 
		 		
		estimates store equil_onlyoppposition;

		
		#delimit;
		set more off;
		
xtpcse pvote
D1.c.ensh_mi
L1.c.ensh_mi

D1.c.ensh_mi#1.inc_cab_l 
L1.c.ensh_mi#L1.1.inc_cab_l

D1.c.GDPgrowth#1.inc_cab_l 
L1.c.GDPgrowth#L1.1.inc_cab_l
D1.c.moderate
L1.c.moderate
D1.c.moderate#1.inc_cab_l 
L1.c.moderate#L1.1.inc_cab_l
1.inc_cab_l  L1.1.inc_cab_l 
D1.c.GDPgrowth L1.c.GDPgrowth

nparty majelect federal directpres equil_pvote  pvote_lag, p ;	 

		estimates store equil_full;
	

/*	Table A10 - Equilibrium Response Models */

#delimit;
 esttab equil_onlyoppposition  equil_onlyincumbents equil_full 
	using "figures\xtpcse_table2_McDonaldandBest.rtf", replace  
		b(%10.3f) se scalars("rmse Root Mean Squared Error" "chi2 \u0935?{\super 2}" )
		obslast star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
		mtitles ( "Opposition" "Incumbents"  "All Parties") 
		nogaps compress   nonumbers  
order(D.ensh_mi L.ensh_mi  
1.inc_cab_l#cD.ensh_mi
1L.inc_cab_l#cL.ensh_mi 
D.moderate
L.moderate
1.inc_cab_l#cD.moderate
1L.inc_cab_l#cL.moderate
D.GDPgrowth L.GDPgrowth 
1.inc_cab_l#cD.GDPgrowth 
1L.inc_cab_l#cL.GDPgrowth 
1.inc_cab_l  1L.inc_cab_l  nparty majelect federal directpres equil_pvote  pvote_lag _cons)  

keep(D.ensh_mi L.ensh_mi  

D.GDPgrowth L.GDPgrowth 
1.inc_cab_l  1L.inc_cab_l 
1.inc_cab_l#cD.ensh_mi
1L.inc_cab_l#cL.ensh_mi 
1.inc_cab_l#cD.GDPgrowth 
1L.inc_cab_l#cL.GDPgrowth 
D.moderate
L.moderate
1.inc_cab_l#cD.moderate
1L.inc_cab_l#cL.moderate
1.inc_cab_l  1L.inc_cab_l  nparty majelect 
federal directpres equil_pvote  pvote_lag _cons) 

coeflabels(D.ensh_mi "\u0916? ENMI"  
L.ensh_mi "ENMI{\sub t-1}" 
1.inc_cab_l "Incumbent{\sub t}"
1L.inc_cab_l "Incumbent{\sub t-1}"
1.inc_cab_l#cD.ensh_mi "Incumbent{\sub t} X \u0916? ENMI"
1L.inc_cab_l#cL.ensh_mi "Incumbent{\sub t-1} X ENMI{\sub t-1}"
D.GDPgrowth "\u0916? GDP Growth Rate"
L.GDPgrowth "GDP Growth Rate{\sub t-1}"
1.inc_cab_l#cD.GDPgrowth "Incumbent{\sub t} X \u0916? GDP Growth Rate"
1L.inc_cab_l#cL.GDPgrowth  "Incumbent{\sub t-1} X GDP Growth Rate{\sub t-1}"
1.inc_cab_l#cD.moderate "Incumbent{\sub t} X \u0916? Moderated Position" 
1L.inc_cab_l#cL.moderate "Incumbent{\sub t-1} X Moderated Position{\sub t-1}"
L.moderate "\u0916? Moderated Position"
D.moderate "Moderated Position{\sub t-1}"
nparty "Niche Party"
majelect "Majoritarian Election"
federal "Federal"
directpres "President"
equil_pvote  "Equilibrium response"
pvote_lag "% Vote{\sub t-1}"
_cons "Constant")

nonotes;


